<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>NeonGlass 管理平台</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        :root {
            --primary: rgba(108, 99, 255, 0.8);
            --primary-solid: rgb(108, 99, 255);
            --secondary: rgba(255, 99, 156, 0.8);
            --dark: rgba(30, 30, 50, 0.9);
            --light: rgba(255, 255, 255, 0.9);
            --text: rgba(255, 255, 255, 0.95);
            --text-secondary: rgba(255, 255, 255, 0.7);
            --bg-gradient-1: #2b1145;
            --bg-gradient-2: #1a1a3a;
            --bg-gradient-3: #162447;
            --bg-gradient-4: #1a3a6e;
            --card-bg: rgba(255, 255, 255, 0.08);
            --card-border: rgba(255, 255, 255, 0.1);
            --sidebar-bg: rgba(255, 255, 255, 0.08);
            --sidebar-border: rgba(255, 255, 255, 0.1);
            --header-bg: rgba(40, 40, 60, 0.9);
            --menu-active-bg: rgba(108, 99, 255, 0.3);
            --menu-active-border: rgb(108, 99, 255);
            --submenu-popup-bg: rgba(40, 40, 60, 0.95);
        }

        /* 明亮主题变量 */
        .light-theme {
            --primary: rgba(78, 115, 223, 0.8);
            --primary-solid: rgb(78, 115, 223);
            --secondary: rgba(233, 84, 32, 0.8);
            --dark: rgba(248, 249, 250, 0.9);
            --light: rgba(255, 255, 255, 0.95);
            --text: rgba(33, 37, 41, 0.95);
            --text-secondary: rgba(108, 117, 125, 0.8);
            --bg-gradient-1: #f8f9fa;
            --bg-gradient-2: #e9ecef;
            --bg-gradient-3: #dee2e6;
            --bg-gradient-4: #ced4da;
            --card-bg: rgba(255, 255, 255, 0.9);
            --card-border: rgba(0, 0, 0, 0.1);
            --sidebar-bg: rgba(255, 255, 255, 0.9);
            --sidebar-border: rgba(0, 0, 0, 0.1);
            --header-bg: rgba(255, 255, 255, 0.9);
            --menu-active-bg: rgba(78, 115, 223, 0.15);
            --menu-active-border: rgb(78, 115, 223);
            --submenu-popup-bg: rgba(255, 255, 255, 0.95);
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
        }
        
        body {
            min-height: 100vh;
            background: linear-gradient(-45deg, var(--bg-gradient-1), var(--bg-gradient-2), var(--bg-gradient-3), var(--bg-gradient-4));
            background-size: 400% 400%;
            animation: gradientBG 15s ease infinite;
            color: var(--text);
            overflow: hidden;
            transition: all 0.5s ease;
        }
        
        @keyframes gradientBG {
            0% { background-position: 0% 50%; }
            50% { background-position: 100% 50%; }
            100% { background-position: 0% 50%; }
        }
        
        /* 玻璃拟态效果 */
        .glass {
            background: var(--card-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border-radius: 12px;
            border: 1px solid var(--card-border);
            box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
        }
        
        .glass-thin {
            background: rgba(255, 255, 255, 0.05);
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
            border: 1px solid rgba(255, 255, 255, 0.05);
        }
        
        /* 布局结构 */
        .app-container {
            display: grid;
            grid-template-columns: 280px 1fr;
            grid-template-rows: 70px 1fr;
            height: 100vh;
            gap: 16px;
            padding: 16px;
            transition: all 0.3s ease;
        }
        
        .app-container.collapsed {
            grid-template-columns: 80px 1fr;
        }
        
        /* 顶部导航栏 */
        .header {
            grid-column: 2;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 24px;
            z-index: 10;
            background: var(--header-bg);
            border-radius: 12px;
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--card-border);
            transition: all 0.5s ease;
        }
        
        .header-left {
            display: flex;
            align-items: center;
            gap: 16px;
        }
        
        .toggle-sidebar {
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 10px;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .toggle-sidebar:hover {
            background: rgba(255, 255, 255, 0.1);
        }
        
        .header-title {
            font-size: 20px;
            font-weight: 600;
            letter-spacing: 0.5px;
        }
        
        .user-panel {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 6px 12px;
            border-radius: 50px;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
        }
        
        .user-panel:hover {
            background: rgba(255, 255, 255, 0.1);
        }
        
        .user-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            object-fit: cover;
            border: 2px solid rgba(255, 255, 255, 0.3);
        }
        
        .user-name {
            font-weight: 500;
            font-size: 14px;
        }
        
        .user-role {
            font-size: 12px;
            color: var(--text-secondary);
        }
        
        .theme-toggle {
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            cursor: pointer;
            transition: all 0.3s ease;
            margin-left: 8px;
        }
        
        .theme-toggle:hover {
            background: rgba(255, 255, 255, 0.1);
        }
        
        /* 侧边栏 */
        .sidebar {
            grid-row: 1 / span 2;
            display: flex;
            flex-direction: column;
            padding: 24px 0 0;
            transition: all 0.3s ease;
            z-index: 20;
            background: var(--sidebar-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--sidebar-border);
            border-radius: 12px;
            overflow: hidden;
        }
        
        .sidebar.collapsed {
            width: 80px;
            align-items: center;
        }
        
        .sidebar.collapsed .logo-text,
        .sidebar.collapsed .menu-text,
        .sidebar.collapsed .submenu {
            display: none;
        }
        
        .sidebar.collapsed .menu-item {
            justify-content: center;
            padding: 12px 0;
            width: 100%;
        }
        
        .logo {
            display: flex;
            align-items: center;
            padding: 0 24px 24px;
            margin-bottom: 16px;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }
        
        .logo-icon {
            font-size: 28px;
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            margin-right: 12px;
        }
        
        .logo-text {
            font-size: 20px;
            font-weight: 700;
            letter-spacing: 1px;
            transition: opacity 0.3s ease;
        }
        
        .menu {
            list-style: none;
            flex: 1;
            overflow-y: auto;
            padding: 0 12px;
        }
        
        .menu-item {
            padding: 12px 16px;
            border-radius: 8px;
            display: flex;
            align-items: center;
            cursor: pointer;
            margin-bottom: 4px;
            transition: all 0.3s ease;
            position: relative;
            overflow: hidden;
        }
        
        .menu-item:hover {
            background: rgba(255, 255, 255, 0.1);
        }
        
        .menu-item.active {
            background: var(--menu-active-bg);
            border-left: 3px solid var(--menu-active-border);
        }
        
        .menu-item.active .menu-icon {
            color: var(--text);
        }
        
        .menu-icon {
            font-size: 18px;
            margin-right: 12px;
            color: var(--text-secondary);
            width: 24px;
            text-align: center;
            transition: all 0.3s ease;
        }
        
        .menu-text {
            flex: 1;
            font-size: 14px;
            font-weight: 500;
            transition: all 0.3s ease;
        }
        
        .submenu-toggle {
            transition: all 0.3s ease;
            font-size: 12px;
            color: var(--text-secondary);
        }
        
        .submenu-toggle.rotated {
            transform: rotate(90deg);
        }
        
        .submenu {
            list-style: none;
            margin-top: 4px;
            margin-left: 40px;
            overflow: hidden;
            max-height: 0;
            transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        }
        
        .submenu.show {
            max-height: 500px;
        }
        
        .submenu-item {
            padding: 10px 16px;
            border-radius: 6px;
            font-size: 13px;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .submenu-item:hover {
            background: rgba(255, 255, 255, 0.05);
            color: var(--text);
        }
        
        .submenu-item.active {
            color: var(--text);
            background: var(--menu-active-bg);
        }
        
        /* 侧边栏底部折叠按钮 */
        .sidebar-footer {
            padding: 16px;
            border-top: 1px solid rgba(255, 255, 255, 0.1);
            display: flex;
            justify-content: flex-end;
        }
        
        .sidebar-toggle {
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .sidebar-toggle:hover {
            background: rgba(255, 255, 255, 0.1);
        }
        
        /* 子菜单弹出框 */
        .submenu-popup {
            position: absolute;
            left: 80px;
            top: 0;
            min-width: 180px;
            background: var(--submenu-popup-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border-radius: 0 12px 12px 12px;
            box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
            z-index: 100;
            opacity: 0;
            pointer-events: none;
            transform: translateX(-10px);
            transition: all 0.3s ease;
            padding: 8px 0;
            border: 1px solid var(--card-border);
        }
        
        .submenu-popup.show {
            opacity: 1;
            pointer-events: auto;
            transform: translateX(0);
        }
        
        .submenu-popup-item {
            padding: 10px 16px;
            font-size: 13px;
            color: var(--text-secondary);
            cursor: pointer;
            transition: all 0.3s ease;
        }
        
        .submenu-popup-item:hover {
            background: rgba(255, 255, 255, 0.05);
            color: var(--text);
        }
        
        /* 主内容区 */
        .main-content {
            display: flex;
            flex-direction: column;
            overflow: hidden;
            transition: all 0.3s ease;
        }
        
        /* 标签页 */
        .tabs-container {
            display: flex;
            border-radius: 12px;
            margin-bottom: 16px;
            position: relative;
            background: var(--card-bg);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border: 1px solid var(--card-border);
        }
        
        .tabs {
            display: flex;
            list-style: none;
            padding: 0 8px;
            width: 100%;
            overflow-x: auto;
        }
        
        .tab {
            padding: 12px 24px;
            cursor: pointer;
            font-size: 14px;
            font-weight: 500;
            color: var(--text-secondary);
            position: relative;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            white-space: nowrap;
            border-bottom: 2px solid transparent;
        }
        
        .tab:hover {
            color: var(--text);
        }
        
        .tab.active {
            color: var(--text);
            border-bottom: 2px solid var(--primary-solid);
            background: rgba(255, 255, 255, 0.05);
        }
        
        .tab-close {
            margin-left: 8px;
            opacity: 0;
            transition: all 0.3s ease;
            width: 18px;
            height: 18px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
        }
        
        .tab:hover .tab-close {
            opacity: 1;
        }
        
        .tab-close:hover {
            background: rgba(255, 255, 255, 0.2);
        }
        
        /* 内容区 */
        .content-area {
            flex: 1;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
        }
        
        .tab-content {
            flex: 1;
            overflow-y: auto;
            padding: 24px;
            display: none;
        }
        
        .tab-content.active {
            display: block;
            animation: fadeIn 0.5s ease;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        /* 仪表板卡片 */
        .dashboard-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
            gap: 16px;
            margin-bottom: 24px;
        }
        
        .stat-card {
            padding: 20px;
            border-radius: 12px;
            transition: all 0.3s ease;
        }
        
        .stat-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.1);
        }
        
        .stat-card .icon {
            width: 48px;
            height: 48px;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            margin-bottom: 16px;
        }
        
        .stat-card h3 {
            font-size: 14px;
            font-weight: 500;
            color: var(--text-secondary);
            margin-bottom: 8px;
        }
        
        .stat-card .value {
            font-size: 24px;
            font-weight: 700;
            margin-bottom: 8px;
        }
        
        .stat-card .change {
            font-size: 12px;
            display: flex;
            align-items: center;
        }
        
        .change.up {
            color: #4ade80;
        }
        
        .change.down {
            color: #f87171;
        }
        
        /* 内容区块 */
        .content-block {
            padding: 24px;
            border-radius: 12px;
            margin-bottom: 24px;
            height: 300px;
            transition: all 0.3s ease;
        }
        
        /* 响应式设计 */
        @media (max-width: 1200px) {
            .app-container {
                grid-template-columns: 80px 1fr;
            }
            
            .app-container:not(.collapsed) {
                grid-template-columns: 280px 1fr;
            }
            
            .sidebar {
                width: 80px;
                align-items: center;
            }
            
            .sidebar:not(.collapsed) {
                width: 280px;
                align-items: stretch;
            }
            
            .sidebar.collapsed .logo-text,
            .sidebar.collapsed .menu-text,
            .sidebar.collapsed .submenu {
                display: none;
            }
            
            .sidebar:not(.collapsed) .logo-text,
            .sidebar:not(.collapsed) .menu-text,
            .sidebar:not(.collapsed) .submenu {
                display: block;
            }
            
            .sidebar.collapsed .menu-item {
                justify-content: center;
                padding: 12px 0;
            }
            
            .sidebar:not(.collapsed) .menu-item {
                justify-content: flex-start;
                padding: 12px 16px;
            }
        }
        
        /* 滚动条样式 */
        ::-webkit-scrollbar {
            width: 6px;
            height: 6px;
        }
        
        ::-webkit-scrollbar-track {
            background: rgba(255, 255, 255, 0.05);
            border-radius: 10px;
        }
        
        ::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.2);
            border-radius: 10px;
        }
        
        ::-webkit-scrollbar-thumb:hover {
            background: rgba(255, 255, 255, 0.3);
        }
    </style>
</head>
<body class="dark-theme">
    <div class="app-container">
        <!-- 侧边栏 -->
        <aside class="sidebar glass">
            <div class="logo">
                <div class="logo-icon">
                    <i class="fas fa-atom"></i>
                </div>
                <div class="logo-text">NeonGlass</div>
            </div>
            
            <ul class="menu">
                <li class="menu-item active" onclick="openTab('dashboard', '仪表盘', this)">
                    <i class="fas fa-tachometer-alt menu-icon"></i>
                    <span class="menu-text">仪表盘</span>
                </li>
                
                <li class="menu-item has-submenu" onmouseenter="showSubmenuPopup(this)" onmouseleave="hideSubmenuPopup(this)">
                    <i class="fas fa-users menu-icon"></i>
                    <span class="menu-text">用户管理</span>
                    <i class="fas fa-chevron-right submenu-toggle"></i>
                    <div class="submenu-popup">
                        <div class="submenu-popup-item" onclick="openTab('users', '用户列表', this)">用户列表</div>
                        <div class="submenu-popup-item" onclick="openTab('roles', '角色管理', this)">角色管理</div>
                        <div class="submenu-popup-item" onclick="openTab('permissions', '权限设置', this)">权限设置</div>
                    </div>
                </li>
                <ul class="submenu">
                    <li class="submenu-item" onclick="openTab('users', '用户列表', this)">用户列表</li>
                    <li class="submenu-item" onclick="openTab('roles', '角色管理', this)">角色管理</li>
                    <li class="submenu-item" onclick="openTab('permissions', '权限设置', this)">权限设置</li>
                </ul>
                
                <li class="menu-item has-submenu" onmouseenter="showSubmenuPopup(this)" onmouseleave="hideSubmenuPopup(this)">
                    <i class="fas fa-box menu-icon"></i>
                    <span class="menu-text">产品管理</span>
                    <i class="fas fa-chevron-right submenu-toggle"></i>
                    <div class="submenu-popup">
                        <div class="submenu-popup-item" onclick="openTab('products', '产品列表', this)">产品列表</div>
                        <div class="submenu-popup-item" onclick="openTab('categories', '分类管理', this)">分类管理</div>
                        <div class="submenu-popup-item" onclick="openTab('inventory', '库存管理', this)">库存管理</div>
                    </div>
                </li>
                <ul class="submenu">
                    <li class="submenu-item" onclick="openTab('products', '产品列表', this)">产品列表</li>
                    <li class="submenu-item" onclick="openTab('categories', '分类管理', this)">分类管理</li>
                    <li class="submenu-item" onclick="openTab('inventory', '库存管理', this)">库存管理</li>
                </ul>
                
                <li class="menu-item" onclick="openTab('analytics', '数据分析', this)">
                    <i class="fas fa-chart-line menu-icon"></i>
                    <span class="menu-text">数据分析</span>
                </li>
                
                <li class="menu-item" onclick="openTab('settings', '系统设置', this)">
                    <i class="fas fa-cog menu-icon"></i>
                    <span class="menu-text">系统设置</span>
                </li>
            </ul>

            <!-- 侧边栏底部折叠按钮 -->
            <div class="sidebar-footer">
                <div class="sidebar-toggle glass-thin" onclick="toggleSidebar()">
                    <i class="fas fa-chevron-left"></i>
                </div>
            </div>
        </aside>
        
        <!-- 顶部导航 -->
        <header class="header glass">
            <div class="header-left">
                <div class="header-title">仪表盘</div>
            </div>
            
            <div style="display: flex; align-items: center;">
                <div class="theme-toggle glass-thin" onclick="toggleTheme()">
                    <i class="fas fa-palette"></i>
                </div>
                <div class="user-panel glass-thin" onclick="toggleUserMenu()">
                    <img src="https://randomuser.me/api/portraits/women/44.jpg" class="user-avatar">
                    <div>
                        <div class="user-name">张雪</div>
                        <div class="user-role">超级管理员</div>
                    </div>
                    <i class="fas fa-chevron-down" style="font-size: 12px;"></i>
                </div>
            </div>
        </header>
        
        <!-- 主内容区 -->
        <main class="main-content glass">
            <!-- 标签页导航 -->
            <div class="tabs-container">
                <ul class="tabs" id="tabs">
                    <li class="tab active" data-tab="dashboard" onclick="switchTab('dashboard')">
                        <span>仪表盘</span>
                        <span class="tab-close" onclick="closeTab(event, 'dashboard')">
                            <i class="fas fa-times"></i>
                        </span>
                    </li>
                </ul>
            </div>
            
            <!-- 内容区 -->
            <div class="content-area">
                <!-- 仪表盘内容 -->
                <div class="tab-content active" id="dashboard">
                    <div class="dashboard-grid">
                        <div class="stat-card glass" style="background: rgba(108, 99, 255, 0.15);">
                            <div class="icon" style="background: rgba(108, 99, 255, 0.2);">
                                <i class="fas fa-users" style="color: var(--primary-solid);"></i>
                            </div>
                            <h3>总用户数</h3>
                            <div class="value">1,248</div>
                            <div class="change up">
                                <i class="fas fa-arrow-up" style="margin-right: 4px;"></i>
                                12.5% 同比
                            </div>
                        </div>
                        
                        <div class="stat-card glass" style="background: rgba(255, 99, 156, 0.15);">
                            <div class="icon" style="background: rgba(255, 99, 156, 0.2);">
                                <i class="fas fa-shopping-cart" style="color: var(--secondary);"></i>
                            </div>
                            <h3>本月订单</h3>
                            <div class="value">356</div>
                            <div class="change up">
                                <i class="fas fa-arrow-up" style="margin-right: 4px;"></i>
                                8.3% 环比
                            </div>
                        </div>
                        
                        <div class="stat-card glass" style="background: rgba(100, 220, 180, 0.15);">
                            <div class="icon" style="background: rgba(100, 220, 180, 0.2);">
                                <i class="fas fa-dollar-sign" style="color: #4ade80;"></i>
                            </div>
                            <h3>总收入</h3>
                            <div class="value">¥48,560</div>
                            <div class="change up">
                                <i class="fas fa-arrow-up" style="margin-right: 4px;"></i>
                                5.2% 环比
                            </div>
                        </div>
                        
                        <div class="stat-card glass" style="background: rgba(255, 180, 70, 0.15);">
                            <div class="icon" style="background: rgba(255, 180, 70, 0.2);">
                                <i class="fas fa-box-open" style="color: #f59e0b;"></i>
                            </div>
                            <h3>库存产品</h3>
                            <div class="value">1,024</div>
                            <div class="change down">
                                <i class="fas fa-arrow-down" style="margin-right: 4px;"></i>
                                2.1% 同比
                            </div>
                        </div>
                    </div>
                    
                    <!-- 内容区块1 -->
                    <div class="content-block glass">
                        <h3 style="margin-bottom: 16px;">自定义内容区域1</h3>
                        <p>这里可以放置您需要的任何内容</p>
                    </div>
                    
                    <!-- 内容区块2 -->
                    <div class="content-block glass">
                        <h3 style="margin-bottom: 16px;">自定义内容区域2</h3>
                        <p>这里可以放置您需要的任何内容</p>
                    </div>
                </div>
                
                <!-- 其他标签页内容 -->
                <div class="tab-content" id="users">
                    <h2>用户列表</h2>
                    <p>这里是用户管理页面内容</p>
                </div>
                
                <div class="tab-content" id="roles">
                    <h2>角色管理</h2>
                    <p>这里是角色管理页面内容</p>
                </div>
                
                <div class="tab-content" id="permissions">
                    <h2>权限设置</h2>
                    <p>这里是权限设置页面内容</p>
                </div>
                
                <div class="tab-content" id="products">
                    <h2>产品列表</h2>
                    <p>这里是产品管理页面内容</p>
                </div>
                
                <div class="tab-content" id="categories">
                    <h2>分类管理</h2>
                    <p>这里是分类管理页面内容</p>
                </div>
                
                <div class="tab-content" id="inventory">
                    <h2>库存管理</h2>
                    <p>这里是库存管理页面内容</p>
                </div>
                
                <div class="tab-content" id="analytics">
                    <h2>数据分析</h2>
                    <p>这里是数据分析页面内容</p>
                </div>
                
                <div class="tab-content" id="settings">
                    <h2>系统设置</h2>
                    <p>这里是系统设置页面内容</p>
                </div>
            </div>
        </main>
    </div>

    <script>
        // 当前打开的标签页
        let currentTab = 'dashboard';
        const tabContents = {};
        let isSidebarCollapsed = false;
        
        // 初始化
        document.addEventListener('DOMContentLoaded', function() {
            // 收集所有标签页内容
            document.querySelectorAll('.tab-content').forEach(tab => {
                tabContents[tab.id] = tab;
            });
            
            // 检查窗口大小，决定是否自动折叠菜单
            checkWindowSize();
            window.addEventListener('resize', checkWindowSize);
            
            // 初始化第一个标签页
            updateTabTitle('仪表盘');
            
            // 加载保存的主题
            const savedTheme = localStorage.getItem('theme') || 'dark';
            if (savedTheme === 'light') {
                document.body.classList.add('light-theme');
            }
        });
        
        // 检查窗口大小，自动折叠菜单
        function checkWindowSize() {
            const appContainer = document.querySelector('.app-container');
            if (window.innerWidth <= 1200) {
                appContainer.classList.add('collapsed');
                document.querySelector('.sidebar').classList.add('collapsed');
                updateToggleIcon(true);
                isSidebarCollapsed = true;
            } else {
                appContainer.classList.remove('collapsed');
                document.querySelector('.sidebar').classList.remove('collapsed');
                updateToggleIcon(false);
                isSidebarCollapsed = false;
            }
        }
        
        // 切换侧边栏展开/折叠状态
        function toggleSidebar() {
            const appContainer = document.querySelector('.app-container');
            const sidebar = document.querySelector('.sidebar');
            
            appContainer.classList.toggle('collapsed');
            sidebar.classList.toggle('collapsed');
            isSidebarCollapsed = sidebar.classList.contains('collapsed');
            
            // 更新按钮图标
            updateToggleIcon(isSidebarCollapsed);
        }
        
        // 更新折叠按钮图标
        function updateToggleIcon(isCollapsed) {
            const toggleBtn = document.querySelector('.sidebar-toggle i');
            if (isCollapsed) {
                toggleBtn.classList.remove('fa-chevron-left');
                toggleBtn.classList.add('fa-chevron-right');
            } else {
                toggleBtn.classList.remove('fa-chevron-right');
                toggleBtn.classList.add('fa-chevron-left');
            }
        }
        
        // 显示子菜单弹出框
        function showSubmenuPopup(element) {
            if (!isSidebarCollapsed) return;
            
            const popup = element.querySelector('.submenu-popup');
            if (popup) {
                // 计算位置
                const rect = element.getBoundingClientRect();
                popup.style.top = `${rect.top}px`;
                popup.classList.add('show');
            }
        }
        
        // 隐藏子菜单弹出框
        function hideSubmenuPopup(element) {
            if (!isSidebarCollapsed) return;
            
            const popup = element.querySelector('.submenu-popup');
            if (popup) {
                popup.classList.remove('show');
            }
        }
        
        // 切换主题
        function toggleTheme() {
            const body = document.body;
            if (body.classList.contains('light-theme')) {
                body.classList.remove('light-theme');
                localStorage.setItem('theme', 'dark');
            } else {
                body.classList.add('light-theme');
                localStorage.setItem('theme', 'light');
            }
        }
        
        // 切换子菜单显示/隐藏
        function toggleSubmenu(element, event) {
            if (isSidebarCollapsed) {
                // 折叠状态下不处理点击事件，由hover触发弹出框
                return;
            }
            
            const submenu = element.nextElementSibling;
            submenu.classList.toggle('show');
            
            // 旋转箭头图标
            const arrow = element.querySelector('.submenu-toggle');
            arrow.classList.toggle('rotated');
        }
        
        // 打开新标签页
        function openTab(tabId, tabName, menuItem) {
            // 如果标签页已存在，直接激活它
            const existingTab = document.querySelector(`.tab[data-tab="${tabId}"]`);
            if (existingTab) {
                switchTab(tabId);
                return;
            }
            
            // 创建新标签
            const tabsContainer = document.getElementById('tabs');
            const newTab = document.createElement('li');
            newTab.className = 'tab';
            newTab.dataset.tab = tabId;
            newTab.innerHTML = `
                <span>${tabName}</span>
                <span class="tab-close" onclick="closeTab(event, '${tabId}')">
                    <i class="fas fa-times"></i>
                </span>
            `;
            newTab.onclick = function() { switchTab(tabId); };
            tabsContainer.appendChild(newTab);
            
            // 激活新标签
            switchTab(tabId);
            
            // 高亮菜单项
            highlightMenuItem(menuItem);
            
            // 更新页面标题
            updateTabTitle(tabName);
        }
        
        // 切换标签页
        function switchTab(tabId) {
            // 更新当前标签页
            currentTab = tabId;
            
            // 更新标签状态
            document.querySelectorAll('.tab').forEach(tab => {
                tab.classList.remove('active');
                if (tab.dataset.tab === tabId) {
                    tab.classList.add('active');
                }
            });
            
            // 更新内容区域
            document.querySelectorAll('.tab-content').forEach(content => {
                content.classList.remove('active');
                if (content.id === tabId) {
                    content.classList.add('active');
                }
            });
        }
        
        // 关闭标签页
        function closeTab(event, tabId) {
            event.stopPropagation(); // 阻止触发标签切换
            
            const tabs = document.querySelectorAll('.tab');
            if (tabs.length <= 1) return; // 至少保留一个标签
            
            const tabToClose = document.querySelector(`.tab[data-tab="${tabId}"]`);
            const isActive = tabToClose.classList.contains('active');
            
            // 移除标签
            tabToClose.remove();
            
            // 如果关闭的是当前活动标签，激活前一个标签
            if (isActive) {
                const remainingTabs = document.querySelectorAll('.tab');
                const lastTab = remainingTabs[remainingTabs.length - 1];
                const newTabId = lastTab.dataset.tab;
                switchTab(newTabId);
                
                // 更新页面标题
                updateTabTitle(lastTab.querySelector('span:first-child').textContent);
            }
        }
        
        // 高亮菜单项
        function highlightMenuItem(menuItem) {
            // 移除所有菜单项的高亮
            document.querySelectorAll('.menu-item, .submenu-item').forEach(item => {
                item.classList.remove('active');
            });
            
            // 高亮当前菜单项
            if (menuItem) {
                menuItem.classList.add('active');
                
                // 如果这是子菜单项，确保父菜单是展开的
                if (menuItem.classList.contains('submenu-item') || menuItem.classList.contains('submenu-popup-item')) {
                    const parentMenu = menuItem.closest('.submenu')?.previousElementSibling || 
                                      document.querySelector(`.menu-item[onclick*="${menuItem.getAttribute('onclick').split("'")[1]}"]`);
                    
                    if (parentMenu && !isSidebarCollapsed) {
                        const submenu = parentMenu.nextElementSibling;
                        if (submenu && !submenu.classList.contains('show')) {
                            submenu.classList.add('show');
                            const arrow = parentMenu.querySelector('.submenu-toggle');
                            if (arrow) arrow.classList.add('rotated');
                        }
                        parentMenu.classList.add('active');
                    }
                }
            }
        }
        
        // 更新页面标题
        function updateTabTitle(title) {
            document.querySelector('.header-title').textContent = title;
        }
        
        // 切换用户菜单
        function toggleUserMenu() {
            alert('用户菜单功能需要进一步实现');
        }
    </script>
</body>
</html>